package com.yanqu.road.server.timer.activity;

import com.yanqu.road.server.manger.cross.CrossDataMgr;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class CrossRankActivityAllSyncTask extends GeneralTask {

    private Logger logger = LogManager.getLogger(this.getClass().getName());

    private long lastCheckTime;

    private final long CHECK_TIME = 30000;       //30秒检测一次

    private boolean isRun = false;

    @Override
    public void doRun() {
        //每天重新加载活动
        long nowTime = System.currentTimeMillis();
        if(nowTime - lastCheckTime > CHECK_TIME && !isRun){
            isRun = true;
            try {
                CrossDataMgr.activityRankAllSync();
                CrossDataMgr.commonActivityRankAllSync();
                CrossDataMgr.activityNewRankAllSync();
                lastCheckTime = nowTime;
            }catch (Exception e){
                logger.error("CrossDataMgr activityRankAllSync error:", e);
            }finally {
                isRun = false;
            }
        }
    }
}
